var global = _g = {
  resizeFunc: [],
  isLoaded:false
};

function registerResize(func) {
  global.resizeFunc.push(func);
}

function onResize() {
  var $win = $(window);
  global.winWidth = global.W = $win.width();
  global.winHeight = global.H = $win.height();

  _.each(global.resizeFunc, function(func) {
    try {
      func.call();
    } catch (e) {}
  });
}

var mousNow = 0;
var mousBool = false;
$(window).mousewheel(function(event, delta, deltaX, deltaY) {
  event.preventDefault();

  if (mousBool) {
    return;
  }
  var he = global.H;
  var len = $(".page").length;

  if (delta > 0) {
    if (mousNow - 1 < 0) {
      return;
    } else
      mousNow--;
  } else {
    if (mousNow + 1 > len - 1) {
      return;
    } else
      mousNow++;
  }
  mousAn(mousNow);
})


function mousAn(mousNow) {
  var he = global.H;

  if (he * mousNow != $(window).scrollTop() && !mousBool) {
    mousBool = true;
    $("body,html").stop(true, false).animate({
      scrollTop: he * mousNow
    }, 500, function() {
      setTimeout(function(){mousBool = false;},500);
    });
  }
};

$(function() {
  $('a.scrolldown,a.scrollup,.menu-list a').smoothScroll({});
  onResize();
  $(window).resize(onResize);
  $('.zp-head').imagefill();
});